<!--
 * @Author: lp 654528967@qq.com
 * @Date: 2022-05-11 15:10:50
 * @LastEditors: lp 654528967@qq.com
 * @LastEditTime: 2022-06-20 17:31:34
 * @FilePath: \nien-vue3-admin\src\views\myMission\personalTasks\completedTasks\index.vue
 * @Description: 已办任务
-->
<template>
  <div>
    <customContainer :config="config" />
    <Detail v-model:visible="visible" :title="title" :data="data" />
  </div>
</template>
<script lang='ts' setup>
import { ref, resolveComponent, onActivated, onDeactivated } from 'vue'
import Detail from '@/views/myMission/components/detail.vue'
import { activitiTaskListFinished, finishedTaskId } from '@/api/myMission/personalTasks/completedTasks'
import { approvalHistory } from '../../hooks'
 
onActivated(() => {
  console.log('激活')
})
onDeactivated(() => {
  console.log('离开')
})
const visible = ref(false)
const title = ref(''), data = ref({})
const config = {
  query: {
    fields: [
      {
        label: '任务名称',
        prop: 'taskName',
      },
    ],
    queryParams: {
      pageSize: 10,
      pageNum: 1,
      taskName: undefined,
    },
  },
  table: {
    columns: [
      // { type: 'index', label: '序号', width: '55' },
      { label: '任务名称', prop: 'processName' },
      // { label: '所属流程', prop: 'taskName' },
      { label: '流程发起人', prop: 'initiator' },
      { label: '任务创建时间', prop: 'taskCreateTime' },
      // { label: '任务结束日期', prop: 'taskName' },
      {
        label: '操作',
        className: 'custormFixedCol',
        showOverflowTooltip: false,
        fixed: 'right',
        render(h, { row }) {
          return h(resolveComponent('ElButton'), {
            onClick: async () => {
              title.value = '审批'
              const { data: resData } = await approvalHistory({ row, visible, api: finishedTaskId, key: 'taskId' })
              data.value = resData
            },
            text: true,
            loading: row.loading,
            type: 'primary',
          }, () => '审批历史')
        },
      },
    ],
    // event: {
    //   onRowClick(e) {
    //     console.log(e) 
    //   },
    // },
  },
  api: activitiTaskListFinished,
  // requestTrans: (q) => {
  //   console.log(q)
  //   return q
  // },
  customKey: 'myMission/personalTasks/completedTasks',
}
</script>
<script lang="ts">
export default {
  name: 'CompletedTasks',
}
</script>